package com.sl.au.repository;

import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import com.sl.au.entity.Account;
import com.sl.au.entity.PartBaseInfo;
import com.sl.au.entity.PartCondition;
import com.sl.au.entity.User;

public interface PartConditionRepository extends JpaRepository<PartCondition, String> {
	
	@Query("select a from PartCondition a where a.partBaseInfo.id = ?1")
	Page<PartCondition> getPageByPart(String partBaseInfoId, Pageable pageable);
	
	@Query("select a from PartCondition a where a.partBaseInfo.id = ?1 and (a.conditionType.title like %?2% or a.content like %?2% )")
	Page<PartCondition> getPageByPartAndKey(String partBaseInfoId, String key, Pageable pageable);
	
	@Modifying
	@Transactional
	@Query("delete from PartCondition a where a.id in (?1)")
	int deleteAllPartConditionByIds(String[] ids);
}